package com.luntan.adapter;

import java.util.List;

import com.luntan.utils.Utils;
import com.luntan.view.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ListItemContentAdapter extends BaseAdapter {
	public Context context;
	public List<String> list;

	public ListItemContentAdapter(Context context, List<String> list) {
		super();
		// TODO Auto-generated constructor stub
		this.context = context;
		this.list = list;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder viewHolder = null;
		if (convertView == null) {
			convertView = LayoutInflater.from(context).inflate(
					R.layout.listitemcontent, null);
			/** 得到各个控件的对象 */
			viewHolder = new ViewHolder();
			viewHolder.title = (TextView) convertView.findViewById(R.id.text);
			viewHolder.text1 = (TextView) convertView.findViewById(R.id.text2);
			viewHolder.text2 = (TextView) convertView
					.findViewById(R.id.itemcontenttexttime);
			viewHolder.text3 = (TextView) convertView
					.findViewById(R.id.itemcontenttextfollor);
			convertView.setTag(viewHolder);
		}
		else{
	        viewHolder = (ViewHolder) convertView.getTag();
	    }
		/** 设置TextView显示的内容，即我们存放在动态数组中的数据 */
		viewHolder.title.setText("大灰狼");
		viewHolder.text1.setText(list.get(position).toString());
		viewHolder.text2.setText(Utils.getCurrentTime());
		viewHolder.text3.setText("1楼");

		return convertView;
	}

	static class ViewHolder {
		public TextView title;
		public TextView text1;
		public TextView text2;
		public TextView text3;
	}
}
